/********************************************************************************************
** Copyright � 2011 Nokia Corporation. All rights reserved.
** Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
** Java and all Java-based marks are trademarks or registered trademarks of
** Sun Microsystems, Inc. Other product and company names mentioned herein may be
** trademarks or trade names of their respective owners.
**
** Subject to the conditions below, you may, without charge:
**
** �  Use, copy, modify and/or merge copies of this software and
**    associated content and documentation files (the �Software�)
**
** �  Publish, distribute, sub-licence and/or sell new software
**    derived from or incorporating the Software.
**
** Some of the documentation, content and/or software maybe licensed under open source
** software or other licenses.  To the extent such documentation, content and/or
** software are included, licenses and/or other terms and conditions shall apply
** in addition and/or instead of this notice. The exact terms of the licenses, disclaimers,
** acknowledgements and notices are reproduced in the materials provided.
**
** This file, unmodified, shall be included with all copies or substantial portions
** of the Software that are distributed in source code form.
**
** The Software cannot constitute the primary value of any new software derived
** from or incorporating the Software.
**
** Any person dealing with the Software shall not misrepresent the source of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************************************************/
import QtQuick 1.0

Rectangle {
    id: maptool
    width: 64
    height: 128
    color: "#00000000"

    signal zoomIn()
    signal zoomOut()
    signal selectarea(bool selecting)
    signal areaselected(string fromorto)
    signal resetArea()

    function selectionToolVisilbe(selectiontool)
    {
        if (selectiontool)
        {
            maptool.height = 192
            maparea.visible = true
        }
        else
        {
            maptool.height = 128
            maparea.visible = false
        }
    }

    Image {
        id: zoomIn
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: parent.top
        anchors.topMargin: 0
        source: "zoominicon.png"

        MouseArea {
            id: mouseareaZoomin
            anchors.fill: parent

            onClicked:
            {
                maptool.zoomIn()
            }
        }
    }

    Image {
        id: zoomOut
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: zoomIn.bottom
        anchors.topMargin: 0
        source: "zoomouticon.png"

        MouseArea {
            id: mouseareaZoomout
            anchors.fill: parent

            onClicked:
            {
                maptool.zoomOut()
            }
        }
    }

    property bool drawingarea: false

    Image {
        id: maparea
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: zoomOut.bottom
        anchors.topMargin: 0
        source: (maptool.drawingarea?"mapareaok.png":"maparea.png")
        visible: false



        MouseArea {
            id: mouseareaMaparea
            anchors.fill: parent

            onClicked:
            {
                mapareatools.visible = !mapareatools.visible

            }

        }
    }

    Rectangle
    {
        id: mapareatools
        visible: false
        width: 192
        height: 64
        color: "#00000000"
        anchors.right: maparea.left
        anchors.rightMargin: 0
        anchors.top: zoomOut.bottom
        anchors.topMargin: 0


        Rectangle
        {
            id: drawarearect
            width: 64
            height: 64
            color: (maptool.drawingarea?"#00FF00":"#00000000")
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 0

            Image {
                id: drawarea
                anchors.fill: parent
                fillMode: Image.Stretch
                source: "drawarea.png"

                property bool okimage: false

                MouseArea {
                    id: mouseareadrawarea
                    anchors.fill: parent

                    onClicked:
                    {
                        maptool.drawingarea = !maptool.drawingarea
                        mapareatools.visible = false
                        maptool.selectarea(maptool.drawingarea)
                        if (!maptool.drawingarea)
                        {
                            maptool.resetArea()
                        }
                    }
                }

            }
        }

        Rectangle
        {
            id: pointsfromarearect
            width: 64
            height: 64
            color: "#00000000"
            anchors.right: drawarearect.left
            anchors.rightMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 0

            Image {
                id: pointsfromarea
                anchors.fill: parent
                fillMode: Image.Stretch
                source: "routeFrom.png"


                property bool okimage: false

                MouseArea {
                    id: mouseareapointsfromarea
                    anchors.fill: parent

                    onPressed: {pointsfromarearect.color= "#00FF00"}
                    onReleased: {pointsfromarearect.color= "#00000000"}

                    onClicked:
                    {
                        maptool.areaselected("FROM")
                        mapareatools.visible = false
                    }
                }

            }
        }

        Rectangle
        {
            id: pointstoarearect
            width: 64
            height: 64
            color: "#00000000"
            anchors.right: pointsfromarearect.left
            anchors.rightMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 0

            Image {
                id: pointstoarea
                anchors.fill: parent
                fillMode: Image.Stretch
                source: "routeTo.png"

                property bool okimage: false

                MouseArea {
                    id: mouseareapointstoarea
                    anchors.fill: parent

                    onPressed: {pointstoarearect.color= "#00FF00"}
                    onReleased: {pointstoarearect.color= "#00000000"}


                    onClicked:
                    {
                        maptool.areaselected("TO")
                        mapareatools.visible = false
                    }
                }

            }
        }
    }

}
